<template>
            <el-table-column v-if='s3'  header-align="center"  :align="align"   :prop="prop"  :label="label"   :key="prop" 
              size="mini" :formatter= "formatter3" :show-overflow-tooltip="true" :render-header="renderHeader"  :width="width" > 
                 <slot ></slot>
              </el-table-column>
            <el-table-column  v-else header-align="center"  :align="align"   :prop="prop"  :label="label"  
             :key="prop" size="mini" :formatter= "formatter" :show-overflow-tooltip="true" 
             :render-header="renderHeader"  :width="width" > 
                 <slot ></slot>
              </el-table-column>
</template>

<script>
  export default {
    name: 'Column',
    props: {
      prop: {
        type: String
      },
      s3:false,
      label: {
        type: String
        
      },
      align: {
        type: String,
        default:"center"
      },
      width:String,
      formatter: Function,
      renderHeader:Function
    },
    methods: {
        formatter3:function(row, column, value, index){
          
               if (!value) return '0.00' 
              var intPart = Math.trunc(value)

              var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
            
              var floatPart = '.00'

              var valueArray = value.toString().split('.')
              if (valueArray.length === 2) { // 有小数部分
                floatPart = valueArray[1].toString() // 取得小数部分
                return intPartFormat + '.' + floatPart
              }
              return intPartFormat 
       
        }

    }
  }
</script>
